<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: wu
  Date: 2018/4/16
  Time: 20:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/bootstrap.min.css">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="${pageContext.request.contextPath}/static/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="${pageContext.request.contextPath}/static/bootstrap.min.js"></script>

</head>
<body>
<%--可增删改所有新闻，新增新闻初始状态为未发布，点击发布可在新闻阅览列表看到，管理员权限--%>
<div class="container-fluid" style="margin: 20px;">
    <div class="row-fluid">
        <div class="span12">

            <form class="form-inline" role="form" action="/newsInfo/findByNewsInfo" method="post">
                <div class="form-group">
                    <label class="sr-only" for="name">名称</label>
                    <input type="text" class="form-control" id="name" name="newsId" placeholder="请输入编号">
                </div>
                <div class="form-group">
                    <label class="sr-only" for="name">名称</label>
                    <input type="text" class="form-control" id="name1" name="title" placeholder="请输入标题">
                </div>
                <div class="form-group">
                    <label class="sr-only" for="name">名称</label>
                    <input type="text" class="form-control" id="name2" name="outLink" placeholder="请输入连接">
                </div>
                <%--<div class="form-group">--%>
                <%--<label class="sr-only" for="name">名称</label>--%>
                <%--<input type="text" class="form-control" id="name3" name="content" placeholder="请输入内容">--%>
                <%--</div>--%>
                <button type="submit" class="btn btn-default">提交</button>
            </form>
            <button type="submit" class="btn btn-default"><a href="/view/addAndUpdateNewsInfo.jsp">添加</a></button>
            <hr>

            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="50px">
                        编号
                    </th>
                    <th width="300px">
                        新闻标题
                    </th>
                    <th width="100px">
                        新闻图片
                    </th>
                    <th width="200px">
                        新闻外部链接
                    </th>
                    <%--<th>--%>
                    <%--新闻内容--%>
                    <%--</th>--%>
                    <th width="70px">
                        状态
                    </th>
                    <th width="220px">
                        操作
                    </th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="newsInfo" items="${newsInfoList}">
                    <tr>
                        <td>
                                ${newsInfo.newsId}
                        </td>
                        <td>
                                ${newsInfo.title}
                        </td>
                        <td>
                                ${newsInfo.image}
                        </td>
                        <td>
                                ${newsInfo.outLink}
                        </td>
                            <%--<td>--%>
                            <%--${newsInfo.content}--%>
                            <%--</td>--%>
                        <td>
                            <c:if test="${newsInfo.status == 'disabled'}">
                                删除
                            </c:if>
                            <c:if test="${newsInfo.status == 'pushed'}">
                                发布
                            </c:if>
                            <c:if test="${newsInfo.status == 'unpush'}">
                                存档
                            </c:if>
                        </td>
                        <td>
                            <nav aria-label="Page navigation">
                                <ul class="pagination">
                                    <li>
                                        <a href="${pageContext.request.contextPath}/newsInfo/deleteNewsInfo?currentPage=1&pageSize=5&newsId=${newsInfo.newsId}"
                                           aria-label="Previous">
                                            <span aria-hidden="true">删除</span>
                                        </a>
                                    </li>
                                    <li>
                                        <a href="/newsInfo/getNewsInfo?newsId=${newsInfo.newsId}" aria-label="Next">
                                            <span aria-hidden="true"
                                                  onclick="page(${pageUtil.currentPage+1},${pageUtil.pageSize})">修改</span>
                                        </a>
                                    </li>
                                </ul>
                            </nav>

                        </td>
                    </tr>
                </c:forEach>
                </tbody>

            </table>

            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li>
                        <a href="${pageContext.request.contextPath}/newsInfo/getAllNewsInfo?currentPage=${pageUtil.currentPage-1}&pageSize=${pageUtil.pageSize}"
                           aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                    <c:forEach var="page" begin="1" end="${pageUtil.totalPage}">
                        <li>
                            <a href="${pageContext.request.contextPath}/newsInfo/getAllNewsInfo?currentPage=${page}&pageSize=${pageUtil.pageSize}">${page}</a>
                        </li>
                    </c:forEach>
                    <li>
                        <a href="${pageContext.request.contextPath}/newsInfo/getAllNewsInfo?currentPage=${pageUtil.currentPage+1}&pageSize=${pageUtil.pageSize}"
                           aria-label="Next">
                            <span aria-hidden="true"
                                  onclick="page(${pageUtil.currentPage+1},${pageUtil.pageSize})">&raquo;</span>
                        </a>
                    </li>
                </ul>
            </nav>

        </div>
    </div>
</div>
</body>
</html>
